<template>
  <div class="">
    <v-header></v-header>
    <main>
      <div class="row">
        <div class="left">热门城市</div>
        <div class="right">
          <ul id="area">
            <li v-for="item in area" :key="item.id">
              <a>{{ item.area_name }}</a>
            </li>
            <!-- <li><a>不限</a></li>
                    <li><a>北京</a></li>
                    <li><a>上海</a></li>
                    <li><a>江苏</a></li>
                    <li><a>济南</a></li>
                    <li><a>河南</a></li>
                    <li><a>天津</a></li>
                    <li><a>沈阳</a></li>
                    <li><a>石家庄</a></li> -->
          </ul>
        </div>
      </div>
      <div class="row">
        <div class="left">按年级选择</div>
        <div class="right">
          <ul id="grade">
            <li v-for="item in grade" :key="item.id">
              <a>{{ item.grade_name }}</a>
            </li>
            <!-- <li><a>不限</a></li>
                    <li><a>一年级</a></li>
                    <li><a>二年级</a></li>
                    <li><a>三年级</a></li>
                    <li><a>四年级</a></li>
                    <li><a>五年级</a></li>
                    <li><a>六年级</a></li>
                    <li><a>初一</a></li>
                    <li><a>初二</a></li>
                    <li><a>初三</a></li>
                    <li><a>高一</a></li>
                    <li><a>高二</a></li>
                    <li><a>高三</a></li> -->
          </ul>
        </div>
      </div>
      <div class="row">
        <div class="left">按学科选择</div>
        <div class="right">
          <ul id="subject">
            <li v-for="item in subject" :key="item.id">
              <a>{{ item.subject_name }}</a>
            </li>
            <!-- <li><a>不限</a></li>
                    <li><a>语文</a></li>
                    <li><a>数学</a></li>
                    <li><a>英语</a></li>
                    <li><a>生物</a></li>
                    <li><a>历史</a></li>
                    <li><a>政治</a></li>
                    <li><a>物理</a></li> -->
          </ul>
        </div>
      </div>
      <div class="row">
        <div class="left">按类别选择</div>
        <div class="right">
          <ul id="category">
            <li v-for="item in category" :key="item.id">
              <a>{{ item.category_name }}</a>
            </li>
            <!-- <li><a>不限</a></li>
                    <li><a class="active">期中</a></li>
                    <li><a>期末</a></li>
                    <li><a>小升初</a></li> -->
          </ul>
        </div>
      </div>
      <div class="lesson">
        <ul id="lesson">
          <li v-for="item in courses" :key="item.id">
            <a href="videoDetail.html">
              <div class="top">
                <img :src="$host + item.image_src" alt="" class="m" />
                <p>学科：{{ item.subject_name }}</p>
              </div>
              <div class="bottom">
                <div class="left">
                  <span>{{ item.title }}</span>
                  <span class="time">地区：{{ item.area_name }}</span>
                </div>
                <div class="right">免费学习</div>
              </div>
            </a>
          </li>
        </ul>
      </div>
      <van-pagination
        v-model="currentPage"
        :total-items="50"
        :show-page-size="5"
      >
        <template #prev-text>
          <van-icon name="arrow-left" />
        </template>
        <template #next-text>
          <van-icon name="arrow" />
        </template>
        <template #page="{ text }">{{ text }}</template>
      </van-pagination>

      <!-- <div class="pageNum">
            <button>上一页</button>
            <ul>
                <li class="active">1</li>
                <li>2</li>
                <li>3</li>
            </ul>
            <button class="active">下一页</button>
        </div> -->
      <ul id="myPager" class="pager" data-ride="pager"></ul>
    </main>
    <v-footer></v-footer>
  </div>
</template>

<script>
import vHeader from "@/components/vHeader.vue";
import VFooter from "@/components/vFooter.vue";
import { courses } from "../http/api";
export default {
  components: { vHeader, VFooter },
  name: "",
  data() {
    return {
      area: [],
      grade: [],
      subject: [],
      category: [],
      courses: [],
      currentPage: 1,
    };
  },
  created() {
    this.$axios.get("/v1/list/area", "/v1/list/grade").then((res) => {
      console.log(res);
      this.area = res.data;
      this.grade = res.data;
    });
    this.$axios.get("/v1/list/grade").then((a) => {
      console.log(a);
      this.grade = a.data;
    });
    this.$axios.get("/v1/list/subject").then((b) => {
      console.log(b);
      this.subject = b.data;
    });
    this.$axios.get("/v1/list/category").then((c) => {
      console.log(c);
      this.category = c.data;
    });
    this.$axios.post("/v1/list/courses").then((d) => {
      console.log(d);
      this.courses = d.data;
    });
  },
  async mounted() {
    let e = await courses();
    console.log(e);
    this.courses = e.data.result;
  },
};
</script>

<style scoped>
main {
  width: 1180px;
  margin: 0 auto;
  margin-top: 22px;
}
main .row {
  min-height: 60px;
  line-height: 40px;
  color: #333;
  font-size: 16px;
  vertical-align: middle;
  width: 1180px;
  height: auto;
}
main .row .left {
  float: left;
  font-weight: Semibold;
  margin-right: 10px;
  color: #222;
  width: 80px;
}
main .row .right {
  float: left;
  width: 1090px;
}
main .row .right span {
  width: 180px;
  height: 40px;
  border: 1px solid #80c4ae;
  border-radius: 4px;
  display: inline-block;
  padding-left: 18px;
  color: #666;
  position: relative;
  font-size: 14px;
  margin-left: 22px;
  cursor: pointer;
}
main .row .right span i {
  color: #80c4ae;
  position: absolute;
  right: 13px;
}
main .row .right .area li {
  float: left;
}
main .row .right ul {
  margin-left: 35px;
}
main .row .right ul li {
  display: inline-block;
  margin-right: 50px;
  color: #666;
  width: 52px;
  text-align: center;
  font-size: 14px;
  box-sizing: border-box;
  cursor: pointer;
}
main .row .right ul li a.active {
  background: #80c4ae;
  color: #fff;
  border-radius: 4px;
  padding: 3px 5px;
}
main .row::after {
  display: block;
  content: "";
  clear: both;
}
main .lesson {
  width: 1180px;
  margin: 20px auto 0;
}
main .lesson ul li {
  width: 370px;
  height: 256px;
  box-shadow: 0 2px 5px #dad6d6;
  background: #fff;
  position: relative;
  overflow: hidden;
  margin: 0 20px 20px 0;
  float: left;
  cursor: pointer;
}
main .lesson ul li:nth-child(3n) {
  margin-right: 0;
}
main .lesson ul li .top {
  width: 380px;
  height: 196px;
  vertical-align: top;
  overflow: hidden;
}
main .lesson ul li .top img.m {
  width: 380px;
  height: 196px;
}
main .lesson ul li .top > p {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 100%;
  height: 33px;
  line-height: 33px;
  font-size: 14px;
  background: #000000;
  color: #fff;
  padding-left: 10px;
  opacity: 0.3;
}
main .lesson ul li .bottom {
  width: 100%;
  height: 62px;
  overflow: hidden;
  line-height: 20px;
  font-size: 14px;
  color: #333;
  margin-top: 7px;
  padding-left: 14px;
}
main .lesson ul li .bottom .left {
  float: left;
}
main .lesson ul li .bottom .left span {
  display: block;
}
main .lesson ul li .bottom .left span.time {
  margin-top: 5px;
  font-size: 14px;
  line-height: 17px;
  color: #7a7a7a;
}
main .lesson ul li .bottom .right {
  float: right;
  margin-top: 12px;
  margin-right: 14px;
  width: 86px;
  height: 30px;
  line-height: 30px;
  font-size: 16px;
  color: #fff;
  background: #74c6b3;
  text-align: center;
  border-radius: 4px;
}
main .lesson ul::after {
  display: block;
  content: "";
  clear: both;
  zoom: 1;
}
main .pageNum {
  width: 1180px;
  height: 40px;
  margin: 0 auto;
  margin-top: 20px;
  text-align: center;
}
main .pageNum ul {
  text-align: center;
  line-height: 25px;
  font-size: 18px;
  display: inline-block;
}
main .pageNum ul li {
  display: inline-block;
  width: 40px;
  height: 40px;
  /* padding: 9px 14px 6px; */
  color: #333;
  background: #ededed;
  border-radius: 4px;
  font-family: PingFangSC-Semibold, PingFang SC;
  margin-right: 12px;
}
main .pageNum ul li.active {
  background: #80c4ae;
  color: #fff;
}
main .pageNum button {
  width: 91px;
  height: 40px;
  outline: none;
  border: none;
  background: #ededed;
  font-size: 18px;
  color: #a4a4a4;
  padding: 9px 19px 6px 18px;
  border-radius: 4px;
  margin: 0 28px;
  font-family: PingFangSC-Semibold, PingFang SC;
}
main .pageNum button.active {
  color: #333;
}
main .pageNum button:last-child {
  margin-left: 8px;
}
</style>
